<!Doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>AWK 内置函数 | 菜鸟教程</title>

  <meta name='robots' content='max-image-preview:large' />
<link rel='stylesheet' id='classic-theme-styles-css' href='../0/classic-themes.min.css?ver=6.2' type='text/css' media='all' />
<link rel="canonical" href="../w3cnote/awk-built-in-functions.html" />
<meta name="keywords" content="AWK 内置函数">
<meta name="description" content="AWK 内置函数主要有以下几种：  算数函数 字符串函数 时间函数 位操作函数 其它函数  算数函数     函数名 说明 实例   atan2( y, x ) 返回 y/x 的反正切。   $ awk &#039;BEGIN {   PI = 3.14159265   x = -10   y = 10   result = atan2 (y,x) * 180 / PI;    printf &#039;The arc tangent ..">
		
	<link rel="shortcut icon" href="https://static.runoob.com/images/favicon.ico">
	<link rel="stylesheet" href="../0/style.css?v=1.170" type="text/css" media="all" />	
	<link rel="stylesheet" href="../0/font-awesome.min.css" media="all" />	
  <!--[if gte IE 9]><!-->
  <script src=""></script>
  <!--<![endif]-->
  <!--[if lt IE 9]>
     <script src=""></script>
     <script src=""></script>
  <![endif]-->
  <link rel="apple-touch-icon" href="https://static.runoob.com/images/icon/mobile-icon.png"/>
  <meta name="apple-mobile-web-app-title" content="菜鸟教程">
</head>
<body>

<!--  头部 -->
<div class="container logo-search">

  <div class="col search row-search-mobile">
    <form action="index.php">
      <input class="placeholder" placeholder="搜索……" name="s" autocomplete="off">
      
    </form>
  </div>

  <div class="row">
    <div class="col logo">
      <h1><a href="../">菜鸟教程 -- 学的不仅是技术，更是梦想！</a></h1>
    </div>
        <div class="col right-list"> 
    <button class="btn btn-responsive-nav btn-inverse" data-toggle="collapse" data-target=".nav-main-collapse" id="pull" style=""> <i class="fa fa-navicon"></i> </button>
    </div>
        
    <div class="col search search-desktop last">
      <div class="search-input" >
      <form action="//www.runoob.com/" target="_blank">
        <input class="placeholder" id="s" name="s" placeholder="搜索……"  autocomplete="off" style="height: 44px;">
      </form>
      
      </div>
    </div>
  </div>
</div>



<!-- 导航栏 -->
<div class="container navigation">
    <div class="row">
        <div class="col nav">
            

                        <ul class="pc-nav" id="note-nav">
                <li><a href="../">首页</a></li>
                <li><a href="../w3cnote">笔记首页</a></li>
                <li><a href="../w3cnote/android-tutorial-intro.html" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" title="ES6 教程">ES6 教程</a></li>
                <li><a href="../w3cnote/ten-sorting-algorithm.html" title="排序算法">排序算法</a></li>
                <li><a href="../w3cnote/hadoop-tutorial.html" title="Hadoop 教程">Hadoop</a></li>
                <li><a href="../w3cnote/zookeeper-tutorial.html" title="Zookeeper 教程">Zookeeper</a></li>
                <li><a href="../w3cnote/verilog-tutorial.html" title="Verilog 教程">Verilog</a></li>
                <li><a href="../w3cnote_genre/code" title="编程技术">编程技术</a></li> 
                <li><a href="../w3cnote_genre/coderlife" title="程序员人生">程序员人生</a></li>
                
                <!--<li><a href="javascript:;" class="runoob-pop">登录</a></li>
                
                
                        <li>
                <a style="font-weight:bold;" href="../linux/linux-tutorial.html#yunserver" target="_blank" onclick="_hmt.push(['_trackEvent', 'aliyun', 'click', 'aliyun'])" title="kkb">云服务器</a>
                </li>
                <li><a href="http://gk.link/a/104mQ" target="_blank" style="font-weight: bold;"onclick="_hmt.push(['_trackEvent', '极客时间', 'click', 'jike'])" title="我的圈子">极客时间</a></li>
            
                
                <li><a target="_blank" href="../shoppinglist" rel="nofollow">知识店铺</a></li> 
        -->
            </ul>
                        
              
            <ul class="mobile-nav">
                <li><a href="../w3cnote">首页</a></li>
                <li><a href="../w3cnote_genre/android" target="_blank" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" target="_blank" title="ES6 教程">ES6</a></li>
                <li><a href="../w3cnote_genre/joke" target="_blank" title="程序员笑话">逗乐</a></li>
                
                <a href="javascript:void(0)" class="search-reveal">Search</a> 
            </ul>
            
        </div>
    </div>
</div>


<!--  内容  -->
<div class="container main">
	<div class="row">

		<div class="col middle-column big-middle-column">
	 			<div class="article">
			<div class="article-heading">
				<h2>AWK 内置函数</h2>				<h3><em>分类</em> <a href="../w3cnote_genre/code" title="编程技术" >编程技术</a> </h3>
			</div>
			<div class="article-body note-body">
				<div class="article-intro">
					<p>AWK 内置函数主要有以下几种：</p>
<ul><li>
<a href="#b1">算数函数</a></li><li>
<a href="#b2">字符串函数</a></li><li>
<a href="#b3">时间函数</a></li><li>
<a href="#b4">位操作函数</a></li><li>
<a href="#b5">其它函数</a></li></ul>

<h3 id="b1">算数函数</h3>

<table class="reference">
<tbody>
<tr>
<th width="15%"><strong>函数名</strong></th>
<th width="30%"><strong>说明</strong></th>
<th><strong>实例</strong></th>
</tr>
<tr>
<td>atan2( y, x )</td>
<td>返回 y/x 的反正切。</td>
<td>
<pre>
$ awk 'BEGIN {
  PI = 3.14159265
  x = -10
  y = 10
  result = atan2 (y,x) * 180 / PI;

  printf "The arc tangent for (x=%f, y=%f) is %f degrees\n", x, y, result
}'
</pre>
<p>输出结果为：</p>
<pre>
The arc tangent for (x=-10.000000, y=10.000000) is 135.000000 degrees
</pre>
</td>
</tr>
<tr>
<td>cos( x )</td>
<td>返回 x 的余弦；x 是弧度。</td>
<td>
<pre>
$ awk 'BEGIN {
  PI = 3.14159265
  param = 60
  result = cos(param * PI / 180.0);

  printf "The cosine of %f degrees is %f.\n", param, result
}'
</pre>
<p>输出结果为：</p>
<pre>
The cosine of 60.000000 degrees is 0.500000.
</pre>
</td>
</tr>
<tr>
<td>sin( x )</td>
<td>返回 x 的正弦；x 是弧度。</td>

<td>
<pre>
$ awk 'BEGIN {
  PI = 3.14159265
  param = 30.0
  result = sin(param * PI /180)

  printf "The sine of %f degrees is %f.\n", param, result
}'
</pre>
<p>输出结果为：</p>
<pre>
The sine of 30.000000 degrees is 0.500000.
</pre>
</td></tr>
<tr>
<td>exp( x )</td>
<td>返回 x 幂函数。</td>
<td>
<pre>
$ awk 'BEGIN {
  param = 5
  result = exp(param);

  printf "The exponential value of %f is %f.\n", param, result
}'
</pre>
<p>输出结果为：</p>
<pre>
The exponential value of 5.000000 is 148.413159.
</pre>
</td>
</tr>
<tr>
<td>log( x )</td>
<td>返回 x 的自然对数。</td>
<td>
<pre>
$ awk 'BEGIN {
  param = 5.5
  result = log (param)

  printf "log(%f) = %f\n", param, result
}'
</pre>
<p>输出结果为：</p>
<pre>
log(5.500000) = 1.704748
</pre>
</td>
</tr>
<tr>
<td>sqrt( x )</td>
<td>返回 x 平方根。</td>
<td>
<pre>
$ awk 'BEGIN {
  param = 1024.0
  result = sqrt(param)

  printf "sqrt(%f) = %f\n", param, result
}'
</pre>
<p>输出结果为：</p>
<pre>
sqrt(1024.000000) = 32.000000
</pre>
</td>
</tr>
<tr>
<td>int( x )</td>
<td>返回 x 的截断至整数的值。</td>
<td>
<pre>
$ awk 'BEGIN {
  param = 5.12345
  result = int(param)

  print "Truncated value =", result
}'
</pre>
<p>输出结果为：</p>
<pre>
Truncated value = 5
</pre>
</td>
</tr>
<tr>
<td>rand( )</td>
<td>返回任意数字 n，其中 0 &lt;= n &lt; 1。</td>
<td>
<pre>
$ awk 'BEGIN {
  print "Random num1 =" , rand()
  print "Random num2 =" , rand()
  print "Random num3 =" , rand()
}'
</pre>
<p>输出结果为：</p>
<pre>
Random num1 = 0.237788
Random num2 = 0.291066
Random num3 = 0.845814
</pre>
</td>
</tr>
<tr>
<td>srand( [Expr] )</td>
<td>将 rand 函数的种子值设置为 Expr 参数的值，或如果省略 Expr 参数则使用某天的时间。返回先前的种子值。</td>
<td>
<pre>
$ awk 'BEGIN {
  param = 10

  printf "srand() = %d\n", srand()
  printf "srand(%d) = %d\n", param, srand(param)
}'
</pre>
<p>输出结果为：</p>
<pre>
srand() = 1
srand(10) = 1417959587
</pre>
</td>
</tr>
</tbody>
</table>


<h3  id="b2">字符串函数</h3>

<table class="reference">
<tbody>
<tr>
<th width="20%"><strong>函数</strong></th>
<th width="35%"><strong>说明</strong></th>
<th><strong>实例</strong></th>
</tr>
<tr>
<td>gsub( Ere, Repl, [ In ] )</td>
<td>gsub 是全局替换( global substitution )的缩写。除了正则表达式所有具体值被替代这点，它和 sub 函数完全一样地执行。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "Hello, World"

    print "String before replacement = " str

    gsub("World", "Jerry", str)

    print "String after replacement = " str
}'
</pre>
<p>输出结果为：</p>
<pre>
String before replacement = Hello, World
String after replacement = Hello, Jerry
</pre>
</td>
</tr>
<tr>
<td>sub(regex,sub,string)</td>
<td>sub 函数执行一次子串替换。它将第一次出现的子串用 regex 替换。第三个参数是可选的，默认为 $0。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "Hello, World"

    print "String before replacement = " str

    sub("World", "Jerry", str)

    print "String after replacement = " str
}'
</pre>
<p>输出结果为：</p>
<pre>
String before replacement = Hello, World
String after replacement = Hello, Jerry
</pre>
</td>
</tr>


<tr>
<td>substr(str, start, l)</td>
<td>substr 函数返回 str 字符串中从第 start 个字符开始长度为 l 的子串。如果没有指定 l 的值，返回 str 从第 start 个字符开始的后缀子串。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "Hello, World !!!"
    subs = substr(str, 1, 5)

    print "Substring = " subs
}'
</pre>
<p>输出结果为：</p>
<pre>
Substring = Hello
</pre>
</td>
</tr>

<tr>
<td>index( String1, String2 )</td>
<td>在由 String1 参数指定的字符串（其中有出现 String2 指定的参数）中，返回位置，从 1 开始编号。如果 String2 参数不在 String1 参数中出现，则返回 0（零）。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "One Two Three"
    subs = "Two"

    ret = index(str, subs)

    printf "Substring \"%s\" found at %d location.\n", subs, ret
}'
</pre>
<p>输出结果为：</p>
<pre>
Substring "Two" found at 5 location.
</pre>
</td>
</tr>
<tr>
<td>length [(String)]</td>
<td>返回 String 参数指定的字符串的长度（字符形式）。如果未给出 String 参数，则返回整个记录的长度（$0 记录变量）。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "Hello, World !!!"

    print "Length = ", length(str)
}'
</pre>
<p>输出结果为：</p>
<pre>
Substring "Two" found at 5 location.
</pre>
</td>
</tr>
<tr>
<td>blength [(String)]</td>
<td>返回 String 参数指定的字符串的长度（以字节为单位）。如果未给出 String 参数，则返回整个记录的长度（$0 记录变量）。</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>substr( String, M, [ N ] )</td>
<td>返回具有 N 参数指定的字符数量子串。子串从 String 参数指定的字符串取得，其字符以 M 参数指定的位置开始。M 参数指定为将 String 参数中的第一个字符作为编号 1。如果未指定 N 参数，则子串的长度将是 M 参数指定的位置到 String 参数的末尾 的长度。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "Hello, World !!!"
    subs = substr(str, 1, 5)

    print "Substring = " subs
}'
</pre>
<p>输出结果为：</p>
<pre>
Substring = Hello
</pre>
</td>
</tr>
<tr>
<td>match( String, Ere )</td>
<td>在 String 参数指定的字符串（Ere 参数指定的扩展正则表达式出现在其中）中返回位置（字符形式），从 1 开始编号，或如果 Ere 参数不出现，则返回 0（零）。RSTART 特殊变量设置为返回值。RLENGTH 特殊变量设置为匹配的字符串的长度，或如果未找到任何匹配，则设置为 -1（负一）。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "One Two Three"
    subs = "Two"

    ret = match(str, subs)

    printf "Substring \"%s\" found at %d location.\n", subs, ret
}'
</pre>
<p>输出结果为：</p>
<pre>
Substring "Two" found at 5 location.
</pre>
</td>
</tr>
<tr>
<td>split( String, A, [Ere] )</td>
<td>将 String 参数指定的参数分割为数组元素 A[1], A[2], . . ., A[n]，并返回 n 变量的值。此分隔可以通过 Ere 参数指定的扩展正则表达式进行，或用当前字段分隔符（FS 特殊变量）来进行（如果没有给出 Ere 参数）。除非上下文指明特定的元素还应具有一个数字值，否则 A 数组中的元素用字符串值来创建。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "One,Two,Three,Four"

    split(str, arr, ",")

    print "Array contains following values"

    for (i in arr) {
        print arr[i]
    }
}'
</pre>
<p>输出结果为：</p>
<pre>
Array contains following values
One
Two
Three
Four
</pre>
</td>
</tr>
<tr>
<td>tolower( String )</td>
<td>返回 String 参数指定的字符串，字符串中每个大写字符将更改为小写。大写和小写的映射由当前语言环境的 LC_CTYPE 范畴定义。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "HELLO, WORLD !!!"

    print "Lowercase string = " tolower(str)
}'
</pre>
<p>输出结果为：</p>
<pre>
Lowercase string = hello, world !!!
</pre>
</td>
</tr>
<tr>
<td>toupper( String )</td>
<td>返回 String 参数指定的字符串，字符串中每个小写字符将更改为大写。大写和小写的映射由当前语言环境的 LC_CTYPE 范畴定义。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = "hello, world !!!"

    print "Uppercase string = " toupper(str)
}'
</pre>
<p>输出结果为：</p>
<pre>
Uppercase string = HELLO, WORLD !!!
</pre>
</td>
</tr>
<tr>
<td>sprintf(Format, Expr, Expr, . . . )</td>
<td>根据 Format 参数指定的 printf 子例程格式字符串来格式化 Expr 参数指定的表达式并返回最后生成的字符串。</td>
<td>
<pre>
$ awk 'BEGIN {
    str = sprintf("%s", "Hello, World !!!")

    print str
}'
</pre>
<p>输出结果为：</p>
<pre>
Hello, World !!!
</pre>
</td>
</tr>


<tr>
<td>strtonum(str)</td>
<td>strtonum 将字符串 str 转换为数值。 如果字符串以 0 开始，则将其当作八进制数；如果字符串以 0x 或 0X 开始，则将其当作十六进制数；否则，将其当作浮点数。</td>
<td>
<pre>
$ awk 'BEGIN {
    print "十进制数 = " strtonum("123")
    print "八进制数 = " strtonum("0123")
    print "十六进制数 = " strtonum("0x123")
}'
</pre>
<p>输出结果为：</p>
<pre>
十进制数 = 123
八进制数 = 83
十六进制数 = 291
</pre>
</td>
</tr>

</tbody>
</table>

<p><strong>注：</strong><span class="marked">Ere</span> 部分可以是正则表达式。</p>



<p><strong>1、gsub、sub 使用</strong></p>

<pre>$ awk 'BEGIN{info="this is a test2012test!";gsub(/[0-9]+/,"||",info);print info}'
this is a test||test!</pre>

<p><strong>2、查找字符串（index 使用）</strong></p>
<p>使用了三元运算符: <span class="marked">表达式 ? 动作1 : 动作2</span></p>

<pre>$ awk 'BEGIN{info="this is a test2012test!";print index(info,"11111")?"ok":"no found";}'
no found
$ awk 'BEGIN{info="this is a test2012test!";print index(info,"is")?"ok":"no found";}'
ok
$ awk 'BEGIN{info="this is a test2012test!";print index(info,"test")?"ok":"no found";}'
ok</pre>
<p><strong>3、正则表达式匹配查找(match 使用）</strong></p>
<pre>$ awk 'BEGIN{info="this is a test2012test!";print match(info,/[0-9]+/)?"ok":"no found";}'
ok</pre>
<p><strong>4、截取字符串(substr使用）</strong></p>
<p>从第 4 个 字符开始，截取 10 个长度字符串。</p>
<pre>$ awk 'BEGIN{info="this is a test2012test!";print substr(info,4,10);}'
s is a tes</pre>

<p><strong>5、字符串分割（split使用）</strong></p>
<pre>$ awk 'BEGIN{info="this is a test";split(info,tA," ");print length(tA);for(k in tA){print k,tA[k];}}'
4
2 is
3 a
4 test
1 this</pre>

<p>分割 info，将 info 字符串使用空格切分为动态数组 tA。注意 awk for …in 循环，是一个无序的循环。 并不是从数组下标 1…n ，因此使用时候需要特别注意。</p>
<p><strong>6、格式化字符串输出（sprintf使用）</strong></p>


<p>其中格式化字符串包括两部分内容: 一部分是正常字符，这些字符将按原样输出; 另一部分是格式化规定字符， 以 <span class="marked">%</span> 开始, 后跟一个或几个规定字符，用来确定输出内容格式。 需要特别注意的是使用 <strong>printf</strong> 时默认是不会换行的，而 <strong>print</strong> 函数默认会在每行后面加上 <span class="marked">\n</span> 换行符。</p>

<table class="reference">
<tbody>
<tr>
<th><strong>格式符</strong></th>
<th><strong>说明</strong></th>
</tr>
<tr>
<td>%d</td>
<td>十进制有符号整数 </td>
</tr>
<tr>
<td>%u</td>
<td>十进制无符号整数 </td>
</tr>
<tr>
<td>%f</td>
<td>浮点数 </td>
</tr>
<tr>
<td>%s</td>
<td>字符串 </td>
</tr>
<tr>
<td>%c</td>
<td>单个字符 </td>
</tr>
<tr>
<td>%p</td>
<td>指针的值 </td>
</tr>
<tr>
<td>%e</td>
<td>指数形式的浮点数 </td>
</tr>
<tr>
<td>%x</td>
<td>%X 无符号以十六进制表示的整数 </td>
</tr>
<tr>
<td>%o</td>
<td>无符号以八进制表示的整数 </td>
</tr>
<tr>
<td>%g</td>
<td>自动选择合适的表示法 </td>
</tr>
</tbody>
</table>
<pre>$ awk 'BEGIN{n1=124.113;n2=-1.224;n3=1.2345; printf("%.2f,%.2u,%.2g,%X,%o\n",n1,n2,n3,n1,n1);}'
124.11,4294967295,1.2,7C,174
$  awk 'BEGIN{n1=124.113;n2=-1.224;n3=1.2645; printf("%.2f,%.2u,%.2g,%X,%o\n",n1,n2,n3,n1,n1);}'
124.11,4294967295,1.3,7C,174</pre>

<p><strong>注：</strong>看上面的 n3 输出值会发现，在使用 printf 处理时一个比较智能的功能是可以进行四舍五入保留小数点位的。</p>
<h3 id="b3">时间函数</h3>

<table class="reference">
<tbody>
<tr>
<th><strong>函数名</strong></th>
<th><strong>说明</strong></th>
<th><strong>实例</strong></th>
</tr>
<tr>
<td>mktime( YYYY MM DD HH MM SS[ DST])</td>
<td>生成时间格式</td>
<td>
<pre>
$ awk 'BEGIN {
    print "Number of seconds since the Epoch = " mktime("2014 12 14 30 20 10")
}'
</pre>
<p>输出结果为：</p>
<pre>
Number of seconds since the Epoch = 1418604610
</pre>
</td>
</tr>
<tr>
<td>strftime([format [, timestamp]])</td>
<td>格式化时间输出，将时间戳转为时间字符串 <br>具体格式，见下表.</td>
<td>
<pre>
$ awk 'BEGIN {
    print strftime("Time = %m/%d/%Y %H:%M:%S", systime())
}'
</pre>
<p>输出结果为：</p>
<pre>
Time = 12/14/2014 22:08:42
</pre>
</td>
</tr>
<tr>
<td>systime()</td>
<td>得到时间戳,返回从1970年1月1日开始到当前时间(不计闰年)的整秒数</td>
<td>
<pre>
awk 'BEGIN{now=systime();print now}'
</pre>
<p>输出结果为：</p>
<pre>
1343210982
</pre>
</td>
</tr>
</tbody>
</table>

<p>strftime 日期和时间格式说明符:</p>
<table class="reference">
<thead>
<tr>
<th>序号</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>%a</td>
<td>星期缩写(Mon-Sun)。</td>
</tr>
<tr>
<td>%A</td>
<td>星期全称（Monday-Sunday）。</td>
</tr>
<tr>
<td>%b</td>
<td>月份缩写（Jan）。</td>
</tr>
<tr>
<td>%B</td>
<td>月份全称（January）。</td>
</tr>
<tr>
<td>%c</td>
<td>本地日期与时间。</td>
</tr>
<tr>
<td>%C</td>
<td>年份中的世纪部分，其值为年份整除100。</td>
</tr>
<tr>
<td>%d</td>
<td>十进制日期(01-31)</td>
</tr>
<tr>
<td>%D</td>
<td>等价于 %m/%d/%y.</td>
</tr>
<tr>
<td>%e</td>
<td>日期，如果只有一位数字则用空格补齐</td>
</tr>
<tr>
<td>%F</td>
<td>等价于 %Y-%m-%d，这也是 ISO 8601 标准日期格式。</td>
</tr>
<tr>
<td>%g</td>
<td>ISO8610 标准周所在的年份模除 100（00-99)。比如，1993 年 1 月 1 日属于 1992 年的第 53 周。所以，虽然它是                     1993 年第 1 天，但是其　ISO8601 标准周所在年份却是 1992。同样，尽管 1973 年 12 月 31 日属于 1973                            年但是它却属于 1994 年的第一周。所以 1973 年 12 月 31 日的 ISO8610　标准周所在的年是 1974 而不是 1973。</td>
</tr>
<tr>
<td>%G</td>
<td>ISO 标准周所在年份的全称。</td>
</tr>
<tr>
<td>%h</td>
<td>等价于 %b.</td>
</tr>
<tr>
<td>%H</td>
<td>用十进制表示的 24 小时格式的小时(00-23)</td>
</tr>
<tr>
<td>%I</td>
<td>用十进制表示的 12 小时格式的小时（00-12）</td>
</tr>
<tr>
<td>%j</td>
<td>一年中的第几天（001-366）</td>
</tr>
<tr>
<td>%m</td>
<td>月份（01-12）</td>
</tr>
<tr>
<td>%M</td>
<td>分钟数（00-59)</td>
</tr>
<tr>
<td>%n</td>
<td>换行符 (ASCII LF)</td>
</tr>
<tr>
<td>%p</td>
<td>十二进制表示法（AM/PM）</td>
</tr>
<tr>
<td>%r</td>
<td>十二进制表示法的时间（等价于 %I:%M:%S %p）。</td>
</tr>
<tr>
<td>%R</td>
<td>等价于 %H:%M。</td>
</tr>
<tr>
<td>%S</td>
<td>时间的秒数值（00-60）</td>
</tr>
<tr>
<td>%t</td>
<td>制表符 (tab)</td>
</tr>
<tr>
<td>%T</td>
<td>等价于 %H:%M:%S。</td>
</tr>
<tr>
<td>%u</td>
<td>以数字表示的星期(1-7),1 表示星期一。</td>
</tr>
<tr>
<td>%U</td>
<td>一年中的第几个星期（第一个星期天作为第一周的开始），00-53</td>
</tr>
<tr>
<td>%V</td>
<td>一年中的第几个星期（第一个星期一作为第一周的开始），01-53。</td>
</tr>
<tr>
<td>%w</td>
<td>以数字表示的星期（0-6），0表示星期日 。</td>
</tr>
<tr>
<td>%W</td>
<td>十进制表示的一年中的第几个星期（第一个星期一作为第一周的开始），00-53。</td>
</tr>
<tr>
<td>%x</td>
<td>本地日期表示</td>
</tr>
<tr>
<td>%X</td>
<td>本地时间表示</td>
</tr>
<tr>
<td>%y</td>
<td>年份模除 100。</td>
</tr>
<tr>
<td>%Y</td>
<td>十进制表示的完整年份。</td>
</tr>
<tr>
<td>%z</td>
<td>时区，表示格式为+HHMM（例如，格式要求生成的 RFC 822或者 RFC 1036 时间头）</td>
</tr>
<tr>
<td>%Z</td>
<td>时区名称或缩写，如果时区待定则无输出。</td>
</tr>
</tbody>
</table>
<h3 id="b4">位操作函数</h3>

<table class="reference">
<tbody>
<tr>
<th><strong>函数名</strong></th>
<th><strong>说明</strong></th>
<th><strong>实例</strong></th>
</tr>
<tr>
<td>and</td>
<td>位与操作。</td>
<td>
<pre>
$ awk 'BEGIN {
    num1 = 10
    num2 = 6

    printf "(%d AND %d) = %d\n", num1, num2, and(num1, num2)
}'
</pre>
<p>输出结果为：</p>
<pre>
(10 AND 6) = 2
</pre>
</td>
</tr>
<tr>
<td>compl</td>
<td>按位求补。</td>
<td>
<pre>
$ awk 'BEGIN {
    num1 = 10

    printf "compl(%d) = %d\n", num1, compl(num1)
}'
</pre>
<p>输出结果为：</p>
<pre>
compl(10) = 9007199254740981
</pre>
</td>
</tr>
<tr>
<td>lshift</td>
<td>左移位操作</td>
<td>
<pre>
$ awk 'BEGIN {
    num1 = 10

    printf "lshift(%d) by 1 = %d\n", num1, lshift(num1, 1)
}'
</pre>
<p>输出结果为：</p>
<pre>
lshift(10) by 1 = 20
</pre>
</td>
</tr>

<tr>
<td>rshift</td>
<td>右移位操作</td>
<td>
<pre>
$ awk 'BEGIN {
    num1 = 10

    printf "rshift(%d) by 1 = %d\n", num1, rshift(num1, 1)
}'
</pre>
<p>输出结果为：</p>
<pre>
rshift(10) by 1 = 5
</pre>
</td>
</tr>
<tr>
<td>or</td>
<td>按位或操作</td>
<td>
<pre>
$ awk 'BEGIN {
    num1 = 10
    num2 = 6

    printf "(%d OR %d) = %d\n", num1, num2, or(num1, num2)
}'
</pre>
<p>输出结果为：</p>
<pre>
(10 OR 6) = 14
</pre>
</td>
</tr>
<tr>
<td>xor</td>
<td>按位异或操作</td>
<td>
<pre>
$ awk 'BEGIN {
    num1 = 10
    num2 = 6

    printf "(%d XOR %d) = %d\n", num1, num2, xor(num1, num2)
}'
</pre>
<p>输出结果为：</p>
<pre>
(10 bitwise xor 6) = 12
</pre>
</td>
</tr>
</tbody>
</table>
<h3 id="b5">其他函数</h3>

<table class="reference">
<tbody>
<tr>
<th><strong>函数名</strong></th>
<th><strong>说明</strong></th>
<th><strong>实例</strong></th>
</tr>
<tr>
<td>close(expr)</td>
<td>关闭管道的文件</td>
<td>
<pre>
$ awk 'BEGIN {
    cmd = "tr [a-z] [A-Z]"
    print "hello, world !!!" |&amp; cmd
    close(cmd, "to")
    cmd |&amp; getline out
    print out;
    close(cmd);
}'
</pre>
<p>输出结果为：</p>
<pre>
HELLO, WORLD !!!
</pre>
<ul>
<li>第一条语句 cmd = "tr [a-z] [A-Z]" 在　AWK 中建立了一个双向的通信通道。</li>
<li>第二条语句 print 为 tr 命令提供输入。&amp;| 表示双向通信。  </li>
<li>第三条语句 close(cmd, "to") 完成执行后关闭 to 进程。  </li>
<li>第四条语句 cmd |&amp; getline out 使用 getline 函数将输出存储到 out 变量中。  </li>
<li>接下来的输出语句打印输出的内容，最后 close 函数关闭 cmd。</li>
</ul>
</td>
</tr>
<tr>
<td>delete</td>
<td>用于从数组中删除元素</td>
<td>
<pre>
$ awk 'BEGIN {
    arr[0] = "One"
    arr[1] = "Two"
    arr[2] = "Three"
    arr[3] = "Four"

    print "Array elements before delete operation:"
    for (i in arr) {
        print arr[i]
    }

    delete arr[0]
    delete arr[1]

    print "Array elements after delete operation:"
    for (i in arr) {
        print arr[i]
    }
}'
</pre>
<p>输出结果为：</p>
<pre>
Array elements before delete operation:
One
Two
Three
Four

Array elements after delete operation:
Three
Four
</pre>
</td>
</tr>
<tr>
<td>exit</td>
<td>终止脚本执行，它可以接受可选的参数 expr 传递 AWK 返回状态。</td>
<td>
<pre>
$ awk 'BEGIN {
    print "Hello, World !!!"

    exit 10

    print "AWK never executes this statement."
}'
</pre>
<p>输出结果为：</p>
<pre>
Hello, World !!!
</pre>
</td>
</tr>

<tr>
<td>flush</td>
<td>刷新打开文件或管道的缓冲区</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>getline</td>
<td>读入下一行</td>
<td>
<p>使用 getline 从文件 marks.txt 中读入一行并输出：</p>
<pre>
$ awk '{getline; print $0}' marks.txt 
</pre>
<p>，AWK 从文件 marks.txt 中读入一行存储到变量 0 中。在下一条语句中，我们使用 getline 读入下一行。因此AWK读入第二行并存储到 0 中。最后，AWK 使用 print 输出第二行的内容。这个过程一直到文件结束。</p>

</td>
</tr>
<tr>
<td>next</td>
<td>停止处理当前记录，并且进入到下一条记录的处理过程。</td>
<td>
<p>当模式串匹配成功后程序并不执行任何操作：</p>
<pre>
$ awk '{if ($0 ~/Shyam/) next; print $0}' marks.txt
</pre>

</td>
</tr>

<tr>
<td>nextfile</td>
<td>停止处理当前文件，从下一个文件第一个记录开始处理。</td>
<td><p>
首先创建两个文件。 file1.txt 内容如下:
</p><pre>
file1:str1
file1:str2
file1:str3
file1:str4</pre><p>
文件 file2.txt 内容如下：
</p><pre>
file2:str1
file2:str2
file2:str3
file2:str4</pre><p>
现在我们来测试 nextfile 函数。</p>
<pre>
$ awk '{ if ($0 ~ /file1:str2/) nextfile; print $0 }' file1.txt file2.txt
</pre>
<p>输出结果为：</p>
<pre>
file1:str1
file2:str1
file2:str2
file2:str3
file2:str4
</pre>
</td>
</tr>


<tr>
<td>return</td>
<td>从用户自定义的函数中返回值。请注意，如果没有指定返回值，那么的返回值是未定义的。</td>
<td>
<p>创建文件 functions.awk，内容如下：</p>
<pre>
function addition(num1, num2)
{
    result = num1 + num2

    return result
}

BEGIN {
    res = addition(10, 20)
    print "10 + 20 = " res
}
</pre><p>
执行该文件：</p><pre>
$ awk -f functions.awk 
10 + 20 = 30
</pre>
</td>
</tr>
<tr>
<td>system</td>
<td>执行特定的命令然后返回其退出状态。返回值为 0 表示命令执行成功；非 0 表示命令执行失败。</td>
<td>
<pre>
$ awk 'BEGIN { ret = system("date"); print "Return value = " ret }'
</pre>
<p>输出结果为：</p>
<pre>
Sun Dec 21 23:16:07 IST 2014
Return value = 0
</pre>
</td>
</tr>
</tbody>
</table>
				</div>
			</div>
			<div class="previous-next-links">
			<div class="previous-design-link">← <a href="../w3cnote/awk-work-principle.html" rel="prev"> AWK 工作原理</a> </div>
			<div class="next-design-link"><a href="../w3cnote/awk-user-defined-functions.html" rel="next"> AWK 用户自定义函数</a> →</div>
			</div>
			<style>
.wrapper {
  /*text-transform: uppercase; */
  background: #ececec;
  color: #555;
  cursor: help;
  font-family: "Gill Sans", Impact, sans-serif;
  font-size: 20px;
  position: relative;
  text-align: center;
  width: 200px;
  -webkit-transform: translateZ(0); /* webkit flicker fix */
  -webkit-font-smoothing: antialiased; /* webkit text rendering fix */
}

.wrapper .tooltip {
  white-space: nowrap;
  font-size: 14px;
  text-align: left;
  background: #96b97d;
  bottom: 100%;
  color: #fff;
  display: block;
  left: -25px;
  margin-bottom: 15px;
  opacity: 0;
  padding: 14px;
  pointer-events: none;
  position: absolute;
  
  -webkit-transform: translateY(10px);
     -moz-transform: translateY(10px);
      -ms-transform: translateY(10px);
       -o-transform: translateY(10px);
          transform: translateY(10px);
  -webkit-transition: all .25s ease-out;
     -moz-transition: all .25s ease-out;
      -ms-transition: all .25s ease-out;
       -o-transition: all .25s ease-out;
          transition: all .25s ease-out;
  -webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
     -moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
      -ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
       -o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
          box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
}
.tooltip a {
	color:#fff;
}
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.wrapper .tooltip:before {
  bottom: -20px;
  content: " ";
  display: block;
  height: 20px;
  left: 0;
  position: absolute;
  width: 100%;
}  

/* CSS Triangles - see Trevor's post */
.wrapper .tooltip:after {
  border-left: solid transparent 10px;
  border-right: solid transparent 10px;
  border-top: solid #96b97d 10px;
  bottom: -10px;
  content: " ";
  height: 0;
  left: 20%;
  margin-left: -13px;
  position: absolute;
  width: 0;
}
.wrapper .tooltip1 {
	margin-left: 50px;
	padding-top: 0px;
}
/*
.wrapper:hover .tooltip {
  opacity: 1;
  pointer-events: auto;
  -webkit-transform: translateY(0px);
     -moz-transform: translateY(0px);
      -ms-transform: translateY(0px);
       -o-transform: translateY(0px);
          transform: translateY(0px);
}
*/
/* IE can just show/hide with no transition */
.lte8 .wrapper .tooltip {
  display: none;
}

.lte8 .wrapper:hover .tooltip {
  display: block;
}

</style>

<link rel="stylesheet" href="../0/upvotejs.css">
<script src=""></script>
<script src=""></script>
<div id="respond" class="no_webshot"> 
		<div class="comment-signarea" style=" padding: 20px 20px;"> 
	<h3 class="text-muted" id="share_code" style="color: #799961;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> 点我分享笔记</h3>
	<!--
	<p style="font-size:14px;">笔记需要是本篇文章的内容扩展！</p><br>
	<p style="font-size:12px;"><a href="../tougao" target="_blank">文章投稿，可点击这里</a></p>
	<p style="font-size:14px;"><a href="../w3cnote/runoob-user-test-intro.html#invite" target="_blank">注册邀请码获取方式</a></p>
		<h3 class="text-muted"><i class="fa fa-info-circle" aria-hidden="true"></i> 分享笔记前必须<a href="javascript:;" class="runoob-pop">登录</a>！</h3>
		<p><a href="../w3cnote/runoob-user-test-intro.html#invite" target="_blank">注册邀请码获取方式</a></p>-->
	</div>
		
	<form action="/wp-content/themes/runoob/option/addnote.php" method="post" id="commentform" style="display:none;">
		<div class="comt">
			<div class="comt-title">
				<i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i>				<p><a id="cancel-comment-reply-link" href="javascript:;">取消</a></p>
			</div>
			<div class="comt-box">
			<div id="mded"></div>
			
				<div class="comt-ctrl">
					<div class="comt-tips"><input type='hidden' name='comment_post_ID' value='20829' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
</div>
					<button type="submit" name="submit" id="submit" tabindex="5"><i class="fa fa-pencil" aria-hidden="true"></i> 分享笔记</button>
				</div>
			</div>
		
				
					<div class="comt-comterinfo"> 
						<ul id="comment-author-info">
							<li class="form-inline"><label class="hide" for="author">昵称</label><input class="ipt" type="text" name="author" id="author" value="" tabindex="2" placeholder="昵称"><span class="text-muted">昵称 (必填)</span></li>
							<li class="form-inline"><label class="hide" for="email">邮箱</label><input class="ipt" type="text" name="email" id="email" value="" tabindex="3" placeholder="邮箱"><span class="text-muted">邮箱 (必填)</span></li>
							<li class="form-inline"><label class="hide" for="url">引用地址</label><input class="ipt" type="text" name="url" id="url" value="" tabindex="4" placeholder="引用地址"><span class="text-muted">引用地址</span></li>
						</ul>
					</div>
				
			
		</div>

	</form>
	</div>
<script type="text/javascript">
$(function() {
	//初始化编辑器
	
	var editor = new Simditor({
	  textarea: $('#mded'),
	  placeholder: '写笔记...',
	  upload:false,
	 // upload: {url:'/api/comment_upload_file.php',params: null,fileKey: 'upload_file',connectionCount: 1,leaveConfirm: '文件正在上传，您确定离开?'},
	  defaultImage: 'https://www.runoob.com/images/logo.png',
	  codeLanguages: '',
	  autosave: 'editor-content',
	  toolbar: [  'bold','code','ul','ol','image' ]
	});
	editor.on('selectionchanged', function() {
		$(".code-popover").hide();
	});

	// 提交数据
	$("#share_code").click(function() {
		$(".comment-signarea").hide();
		$("#commentform").show();
		
	});
	$("#user_add_note").click(function() {
		$(".comment-signarea").hide();
		$("#commentform").show();
		$('html, body').animate({
       	    scrollTop: $("#respond").offset().top
    	}, 200);
	});

	// 提交笔记
	var commentform=$('#commentform');
	commentform.prepend('<div id="comment-status" style="display:none;" ></div>');
	var statusdiv=$('#comment-status');
	
	commentform.submit(function(e){
		e.preventDefault();
		var noteContent = editor.getValue();
		// console.log(noteContent);
		noteContent = noteContent.replace(/<pre><code>/g,"<pre>");
		noteContent = noteContent.replace(/<\/code><\/pre>/g,"</pre>");
		
		// 系列化表单数据
		var comment_parent = 0;
		var is_user_logged_in = $("#is_user_logged_in").val();
		var comment_post_ID =  20829;
		var _wp_unfiltered_html_comment = $("#_wp_unfiltered_html_comment").val();
		var comment = noteContent;
		var author = $("#author").val();
		var url = $("#url").val();
		var email = $("#email").val();
		if(isBlank(author) && is_user_logged_in==0) {
			statusdiv.html('<p  class="ajax-error">请输入昵称！</p>').show();
		} else if(isBlank(email)  && is_user_logged_in==0) {
			statusdiv.html('<p  class="ajax-error">请输入邮箱！</p>').show();
		} else {
			// var formdata=commentform.serialize() + "&comment=" + noteContent ;
			// 添加状态信息
			statusdiv.html('<p>Processing...</p>').show();
			// 获取表单提交地址
			var formurl=commentform.attr('action');
			
			// 异步提交
			$.ajax({
					type: 'post',
					url: formurl,
					dataType:'json',
					data: {"comment_parent":comment_parent,"comment_post_ID":comment_post_ID, "_wp_unfiltered_html_comment":_wp_unfiltered_html_comment,"comment":comment,"url":url, "email":email,"author":author},
					error: function(XMLHttpRequest, textStatus, errorThrown){
					statusdiv.html('<p class="ajax-error" >数据不完整或表单提交太快了！</p>').show();
				},
				success: function(data, textStatus){
					if(data.errorno=="0") {
						$("#submit").prop('disabled', true);
						statusdiv.html('<p class="ajax-success" >笔记已提交审核，感谢分享笔记！</p>').show();
						alert('笔记已提交审核，感谢分享笔记！');
					}else{
						statusdiv.html('<p class="ajax-error" >'+data.msg+'</p>').show();
					}
					commentform.find('textarea[name=comment]').val('');
				}
			});
			setTimeout(function(){
		        $("#submit").prop('disabled', false);
		    }, 10*1000);
		}
		return false;

	});
	$(".comt-author").click(function() {
		href = $(this).children("a").attr("href");
		if(href.indexOf("/note/")!=-1) {
			var win = window.open(href, '_blank');
  			win.focus();
		}
	});
	$(".comt-meta span").hover(function(){
		$(this).children(".tooltip").css({ "opacity": 1, "pointer-events": "auto"});
	},function(){
		$(this).children(".tooltip").removeAttr("style");
	});
	/*
	$(".wrapper i").hover(function(){
		$(this).siblings(".tooltip").css({ "opacity": 1, "pointer-events": "auto"});
	},function(){
		$(this).siblings(".tooltip").css({ "opacity": 0, "pointer-events": "auto"});
	});
	*/
	//Upvote.create('runoobvote-id', {callback: vote_callback});
	var ajaxurl = 'https://www.runoob.com/wp-admin/admin-ajax.php';
	var callback = function(data) {
		//console.log($('#runoobvote-id').upvote('upvoted'));
		//console.log($('#runoobvote-id').upvote('downvoted'));
		//console.log(data);
		_vote_action = data.action;
		id_arr = data.id.split('-');
		um_id= id_arr[2];
		//console.log(um_id);
		
		var re = /^[1-9]+/;
		if (re.test(um_id)) { 
			var ajax_data = {
				_vote_action: _vote_action,
				action: "pinglun_zan",
				um_id: um_id,
				um_action: "ding"
			};
			//console.log(ajax_data);
			$.post(ajaxurl,ajax_data,function(status){
				//if(status.vote_num>999) {
				//	_voteHtml = '<span style="display: block; text-align: center;font-size: 20px; color: #6a737c; margin: 8px 0;">'+kFormatter(status.vote_num) +'</span>';
				//	$("#runoobvote-id-" + um_id + " .count").hide().after(_voteHtml);
				//}
				
			});
		}
	};
	if($('#comments').length && $('.upvotejs').length){
		$('.upvotejs').upvote({id: 20829, callback: callback});
	
		$.post(ajaxurl,{"action":"pinglun_zan","postid":20829},function(data){  
			$(data).each(function(key,value) {
				$("#runoobvote-id-" + value.commid + " .upvote").addClass(value.upvotejs_class);
				$("#runoobvote-id-" + value.commid + " .downvote").addClass(value.downvote_class);
				$("#runoobvote-id-" + value.commid + " .count").text(value.upvote_count);
			})
		},'json');
		
	}
	
	
});
function isBlank(str) {
    return (!str || /^\s*$/.test(str));
}
function kFormatter(num) {
	// return num;
    return Math.abs(num) > 999 ? Math.sign(num)*((Math.abs(num)/1000).toFixed(1)) + 'k' : Math.sign(num)*Math.abs(num)
}

</script>

<link rel="stylesheet" href="../0/qa.css?1.44">
<link rel="stylesheet" type="text/css" href="../0/simditor.min.css" />
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
			<div class="article-heading-ad" id="w3cnote-ad728">
			<script async src=""></script>
			<!-- 移动版 自动调整 -->
			<ins class="adsbygoogle"
			     style="display:inline-block;min-width:300px;max-width:970px;width:100%;height:90px"
			     data-ad-client="ca-pub-5751451760833794"
			     data-ad-slot="1691338467"
			     data-ad-format="horizontal"></ins>
			<script>
			(adsbygoogle = window.adsbygoogle || []).push({});
			</script>
			</div>
			<style>
@media screen and (max-width: 768px) {
	#w3cnote-ad728 {
		display: none;
	}
}
p.note-author {
    border-bottom: 1px solid #ddd;
    font-size: 18px;
    font-weight: bold;
    color: #78a15a;
    padding-bottom: 2px;
    margin-bottom: 4px;
}
</style>
<script>
var aid = 20829;
</script>
	</div>
		
	</div>
	<div class="listcol last right-column">




<!--
	<div class="tab tab-light-blue"> 订阅</div>
	<div class="sidebar-box">
		<div class="socialicons">
			<a href="../feed" class="rss">RSS 订阅</a>
		
			<form action="//list.qq.com/cgi-bin/qf_compose_send" method="post">
			<input type="hidden" value="qf_booked_feedback" name="t">
			<input type="hidden" value="4b67b6b6c1f5e792559940cab4aebb8f1126fba880bff1a8" name="id">
			<input class="placeholder" id="feed_email" name="to" value="输入邮箱 订阅笔记" autocomplete="off">
			<input type="submit" value="订阅" class="btn btn-primary">
			</form>
		
		</div>
 
	</div>
-->	



<!--
	<div class="sidebar-box cate-list">
	<div class="sidebar-box recommend-here list-link">
			<a href="javascript:void(0);" style="font-size: 16px; color:#64854c;font-weight:bold;">笔记列表</a>
		</div>

 

</div>
-->

	 <div class="sidebar-box cate-list">
		 		

	 	<div class="sidebar-box recommend-here list-link">
			<a href="javascript:void(0);" style="font-size: 16px; color:#64854c;font-weight:bold;">教程列表</a>
		</div>
		
		<div class="cate-items"> 
				<a href="../ado">ADO 教程</a>
	<a href="../ajax">Ajax 教程</a>
	<a href="../android">Android 教程</a>
	<a href="../angularjs2">Angular2 教程</a>
	<a href="../angularjs">AngularJS 教程</a>
	<a href="../appml">AppML 教程</a>
	<a href="../asp">ASP 教程</a>
	<a href="../aspnet">ASP.NET 教程</a>
	<a href="../bootstrap">Bootstrap 教程</a>
	<a href="../bootstrap4">Bootstrap4 教程</a>
	<a href="../bootstrap5">Bootstrap5 教程</a>
	<a href="../cprogramming">C 教程</a>
	<a href="../csharp">C# 教程</a>
	<a href="../cplusplus">C++ 教程</a>
	<a href="../chartjs">Chart.js 教程</a>
	<a href="../cssref">CSS 参考手册</a>
	<a href="../css">CSS 教程</a>
	<a href="../css3">CSS3 教程</a>
	<a href="../django">Django 教程</a>
	<a href="../docker">Docker 教程</a>
	<a href="../dtd">DTD 教程</a>
	<a href="../echarts">ECharts 教程</a>
	<a href="../eclipse">Eclipse 教程</a>
	<a href="../firebug">Firebug 教程</a>
	<a href="../font-awesome">Font Awesome 图标</a>
	<a href="../foundation">Foundation 教程</a>
	<a href="../git">Git 教程</a>
	<a href="../go">Go 语言教程</a>
	<a href="../googleapi">Google 地图 API 教程</a>
	<a href="../highcharts">Highcharts 教程</a>
	<a href="../htmldom">HTML DOM 教程</a>
	<a href="../tags">HTML 参考手册</a>
	<a href="../charsets">HTML 字符集</a>
	<a href="../html">HTML 教程</a>
	<a href="../http">HTTP 教程</a>
	<a href="../ionic">ionic 教程</a>
	<a href="../ios">iOS 教程</a>
	<a href="../java">Java 教程</a>
	<a href="../jsref">JavaScript 参考手册</a>
	<a href="../js">Javascript 教程</a>
	<a href="../jeasyui">jQuery EasyUI 教程</a>
	<a href="../jquerymobile">jQuery Mobile 教程</a>
	<a href="../jqueryui">jQuery UI 教程</a>
	<a href="../jquery">jQuery 教程</a>
	<a href="../json">JSON 教程</a>
	<a href="../jsp">JSP 教程</a>
	<a href="../julia">Julia 教程</a>
	<a href="../kotlin">Kotlin 教程</a>
	<a href="../linux">Linux 教程</a>
	<a href="../lua">Lua 教程</a>
	<a href="../markdown">Markdown 教程</a>
	<a href="../matplotlib">Matplotlib 教程</a>
	<a href="../maven">Maven 教程</a>
	<a href="../memcached">Memcached 教程</a>
	<a href="../mongodb">MongoDB 教程</a>
	<a href="../mysql">MySQL 教程</a>
	<a href="../nodejs">Node.js 教程</a>
	<a href="../numpy">NumPy 教程</a>
	<a href="../pandas">Pandas 教程</a>
	<a href="../perl">Perl 教程</a>
	<a href="../php">PHP 教程</a>
	<a href="../postgresql">PostgreSQL 教程</a>
	<a href="../python3">Python 3 教程</a>
	<a href="../python">Python 基础教程</a>
	<a href="../r">R 教程</a>
	<a href="../rdf">RDF 教程</a>
	<a href="../react">React 教程</a>
	<a href="../redis">Redis 教程</a>
	<a href="../rss">RSS 教程</a>
	<a href="../ruby">Ruby 教程</a>
	<a href="../rust">Rust 教程</a>
	<a href="../sass">Sass 教程</a>
	<a href="../scala">Scala 教程</a>
	<a href="../scipy">SciPy 教程</a>
	<a href="../servlet">Servlet 教程</a>
	<a href="../soap">SOAP 教程</a>
	<a href="../sql">SQL 教程</a>
	<a href="../sqlite">SQLite 教程</a>
	<a href="../svg">SVG 教程</a>
	<a href="../svn">SVN 教程</a>
	<a href="../swift">Swift 教程</a>
	<a href="../tcpip">TCP/IP 教程</a>
	<a href="../typescript">TypeScript 教程</a>
	<a href="../vbscript">VBScript 教程</a>
	<a href="../vue2">Vue.js 教程</a>
	<a href="../vue3">Vue3 教程</a>
	<a href="../w3c">W3C 教程</a>
	<a href="../webservices">Web Service 教程</a>
	<a href="../wsdl">WSDL 教程</a>
	<a href="../xlink">XLink 教程</a>
	<a href="../dom">XML DOM 教程</a>
	<a href="../schema">XML Schema 教程</a>
	<a href="../xml">XML 教程</a>
	<a href="../xpath">XPath 教程</a>
	<a href="../xquery">XQuery 教程</a>
	<a href="../xslfo">XSLFO 教程</a>
	<a href="../xsl">XSLT 教程</a>
	<a href="../data-structures">数据结构</a>
	<a href="../regexp">正则表达式</a>
	<a href="../quiz">测验</a>
	<a href="../browsers">浏览器</a>
	<a href="../quality">网站品质</a>
	<a href="../web">网站建设指南</a>
	<a href="../hosting">网站服务器教程</a>
	<a href="../design-pattern">设计模式</a>
			
		</div> 
		 	 </div>
</div>
	</div>
</div>


<!-- 底部 -->
<div id="footer" class="mar-t50">
   <div class="runoob-block">
    <div class="runoob cf">
     <dl>
      <dt>
       在线实例
      </dt>
      <dd>
       &middot;<a target="_blank" href="../html/html-examples.html">HTML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../css/css-examples.html">CSS 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../js/js-examples.html">JavaScript 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../ajx/ajax-examples.html">Ajax 实例</a>
      </dd>
       <dd>
       &middot;<a target="_blank" href="../jquery/jquery-examples.html">jQuery 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../xml/xml-examples.html">XML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../java/java-examples.html">Java 实例</a>
      </dd>
     
     </dl>
     <dl>
      <dt>
      字符集&工具
      </dt>
      <dd>
       &middot; <a target="_blank" href="../charsets/html-charsets.html">HTML 字符集设置</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-ascii.html">HTML ASCII 字符集</a>
      </dd>
     <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6939/">JS 混淆/加密</a>
      </dd> 
      <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6232/">PNG/JPEG 图片压缩</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-colorpicker.html">HTML 拾色器</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/53">JSON 格式化工具</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/6680/">随机数生成器</a>
      </dd>
     </dl>
     <dl>
      <dt>
       最新更新
      </dt>
                   <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imread.html" title="Matplotlib imread() 方法">Matplotlib imre...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imsave.html" title="Matplotlib imsave() 方法">Matplotlib imsa...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imshow.html" title="Matplotlib imshow() 方法">Matplotlib imsh...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-hist.html" title="Matplotlib 直方图">Matplotlib 直方图</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-func-object.html" title="Python object() 函数">Python object()...</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-ai-draw.html" title="Python AI 绘画">Python AI 绘画</a>
      </dd>
              <dd>
       &middot;
      <a href="../w3cnote/cursor-editor.html" title="神辅助 Cursor 编辑器，加入 GPT-4 让编码更轻松！">神辅助 Cursor ...</a>
      </dd>
             </dl>
     <dl>
      <dt>
       站点信息
      </dt>
      <dd>
       &middot;
       <a target="_blank" href="mailto:admin@runoob.com" rel="external nofollow">意见反馈</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../disclaimer">免责声明</a>
       </dd>
      <dd>
       &middot;
       <a target="_blank" href="../aboutus">关于我们</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../archives">文章归档</a>
      </dd>
    
     </dl>
    
     <div class="search-share">
      <div class="app-download">
        <div>
         <strong>关注微信</strong>
        </div>
      </div>
      <div class="share">
      <img width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png" />
       </div>
     </div>
     
    </div>
   </div>
   <div class="w-1000 copyright">
     Copyright &copy; 2013-2023    <strong><a href="../" target="_blank">菜鸟教程</a></strong>&nbsp;
    <strong><a href="../" target="_blank">runoob.com</a></strong> All Rights Reserved. 备案号：<a target="_blank" rel="nofollow" href="https://beian.miit.gov.cn/">闽ICP备15012807号-1</a>
   </div>
  </div>
  <div class="fixed-btn">
    <a class="go-top" href="javascript:void(0)" title="返回顶部"> <i class="fa fa-angle-up"></i></a>
    <a class="qrcode"  href="javascript:void(0)" title="关注我们"><i class="fa fa-qrcode"></i></a>
    <a class="writer" style="display:none" href="javascript:void(0)"   title="标记/收藏"><i class="fa fa-star" aria-hidden="true"></i></a>
    <!-- qrcode modal -->
    <div id="bottom-qrcode" class="modal panel-modal hide fade in">
      <h4>微信关注</h4>
      <div class="panel-body"><img alt="微信关注" width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png"></div> 
    </div>
  </div>

 <div style="display:none;">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-84264393-2"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-84264393-2');
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3eec0b7da6548cf07db3bc477ea905ee";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</div>
<script>
window.jsui={
    www: 'https://www.runoob.com',
    uri: 'https://www.runoob.com/wp-content/themes/runoob'
};
</script>

<script src=""></script>
<script src=""></script>

</body>
</html>